
(function (doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function () {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            if(clientWidth==750){
                docEl.style.fontSize = '100px';
            }else{
                docEl.style.fontSize = 100 * (clientWidth / 750) + 'px';
            }
        };
    if (!doc.addEventListener) return;
    win.addEventListener(resizeEvt, recalc, false);
    doc.addEventListener('DOMContentLoaded', recalc, false);
})(document, window);
function getParams() {
	var tjsj = $("form").serializeArray();
	var json = {};
	for (var i = 0; i < tjsj.length; i++) {
		var ob = tjsj[i];
		if(ob.name=='calllurl'){
			continue;
		}
		json[ob.name] = ob.value;
	}
	return json;
}

function mzpost(option){
    var contentType = 'application/x-www-form-urlencoded';
    var processData = true;
    if(option.contentType != null){
        contentType = option.contentType;
    }
    if(option.processData != null){
        processData = option.processData;
    }
    $.ajax({
        url:option.url,
        type:"post",
        processData:processData,
        data:option.data,
        contentType:contentType,
        success:function(data){
            if(typeof data == 'string'){
                var res = JSON.parse(data);
                option.success(res);
            }else{
                option.success(res);
            }
           
        },
        error:option.error
    })
}
function mzget(option){
    $.ajax({
        url:option.url,
        type:"get",
        success:function(data){
            if(typeof data == 'string'){
                var res = JSON.parse(data);
                option.success(res);
            }else{
                option.success(res);
            }
        },
        error:option.error
    })
}



function formateDate(param) {

    var now =new Date(parseInt(param) * 1000); 
    var year=now.getFullYear(); 
    var month=now.getMonth()+1; 
    var date=now.getDate(); 
    var hour=now.getHours(); 
    var minute=now.getMinutes(); 
    var second=now.getSeconds(); 
    return year+"-"+changenum(month)+"-"+changenum(date)+" "+changenum(hour)+":"+changenum(minute)+":"+changenum(second); 
} 

function changenum(param){
    var str = Number(param).toString()
    if(str.length == 1){
        return '0'+str;
    }else{
        return str;
    }
}


//获取链接参数
function getParameter(param) {
    var query = window.location.search;
    var iLen = param.length;
    var iStart = query.indexOf(param);
    if (iStart == -1) return "";
    iStart += iLen + 1;var iEnd = query.indexOf("&", iStart);
    try {
        if (iEnd == -1)
            return decodeURI(query.substring(iStart));
    } catch (e) {
        return query.substring(iStart);
    }
    try {
        return decodeURI(query.substring(iStart, iEnd));
    } catch (e) {
        return query.substring(iStart, iEnd);
    }
}


function downloadIamge(select,name) {
    // 通过选择器获取img元素
    var img = document.querySelector(select);
    // 将图片的src属性作为URL地址
    var url = img.src
    var a = document.createElement('a');
    var event = new MouseEvent('click');
    
    a.download = name
    a.href = url
    
    a.dispatchEvent(event)
}

$(document).ready(function(){
    mui('.mui-bar-tab').on('tap','a',function(){document.location.href=this.href;});
})





function setCookie(name,value){
    var Days = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}
function getCookie(name){
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
    if(arr=document.cookie.match(reg)){
        return unescape(arr[2]);
    }else{
        return null;
    }
}
function delCookie(name){
    var exp = new Date();
    exp.setTime(exp.getTime() - 1000);
    var cval=getCookie(name);
    if(cval!=null){
        document.cookie= name + "="+cval+";expires="+exp.toGMTString();
    } 
}


function clearAllCookie() {
    var date=new Date();
    date.setTime(date.getTime()-10000);
    var keys=document.cookie.match(/[^ =;]+(?=\=)/g);
    if (keys) {
        for (var i =  keys.length; i--;)
          document.cookie=keys[i]+"=0; expire="+date.toGMTString()+"; path=/";
    }
}